<!--_meta 作为公共模版分离出去-->
{include file="public/meta"}
<title>添加管理员 - 管理员管理</title>
</head>
<body>
<article class="cl pd-20">
	<form action="{:url('admin/userto')}" method="post" class="form form-horizontal" id="form-admin-add">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>账号：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="" placeholder="" id="username" name="username">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>密码：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="password" class="input-text" autocomplete="off" value="" placeholder="密码" id="password" name="password">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="" placeholder="" id="uuserPhone" name="uuserPhone">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>角色：</label>
			<div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
				<select class="select" name="a_role"  id="a_role" size="1">
				<option value="0">选择角色</option>
				  {foreach name="roleList" item="val"}
					<option value="{$val.id}">{$val.name}</option>
				  {/foreach}	
				</select>
				</span> </div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                <button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;返回列表&nbsp;&nbsp;</button>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <button id="bt_sub" class="btn btn-primary radius" type="button">&nbsp;&nbsp;创建&nbsp;&nbsp;</button>
            </div>
		</div>
	</form>
</article>
<!--_footer 作为公共模版分离出去-->
{include file="public/footer"}
<!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
$(function(){
	$('#bt_sub').click(function (){
            var bt_sub = $(this);
            var username = $('#username').val();
            if (username == '' || username == undefined) {
                layer.msg('请填写账号!', {icon: 7, time: 1000});
                return false;
            }
            var password = $('#password').val();
            if (password == '' || password == undefined) {
                layer.msg('请填写密码!', {icon: 7, time: 1000});
                return false;
            }
            var uuserPhone = $('#uuserPhone').val();
            if (uuserPhone == '' || uuserPhone == undefined) {
                layer.msg('请填写手机号!', {icon: 7, time: 1000});
                return false;
            }
            var uuserPhone = $('#uuserPhone').val();
            if (uuserPhone == '' || uuserPhone == undefined) {
                layer.msg('请填写手机号!', {icon: 7, time: 1000});
                return false;
            }
            bt_sub.attr('disabled', 'disabled');
              var formData = new FormData();
            $.each($("#form-admin-add").serializeArray(), function (i, field) {
                formData.append(field.name, field.value);
            });
            $.ajax({
                url: $('#form-admin-add').attr('action'),
                type: 'POST',
                data: formData,
                processData: false,// 告诉jQuery不要去处理发送的数据
                contentType: false,// 告诉jQuery不要去设置Content-Type请求头
                success: function (res) {
                    if (res.state == 1) {
                        window.parent.layer.msg(res.msg, {icon: 1, time: 1000});
                        setTimeout(function () {
                            window.parent.location.reload();
                        }, 1200);
                    }else {
                        layer.msg(res.msg, {icon: 7, time: 1000});
                        bt_sub.removeAttr('disabled');
                    }
                },
                error: function (res) {
                    layer.msg('网络错误，请关闭重试!', {icon: 2, time: 1000});
                    bt_sub.removeAttr('disabled');
                }
            });
        });
});
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>